package main

import (
	"fmt"
	"sync"
	"time"
)

type instance struct {
	cnt int
}

var (
	once sync.Once
	in   *instance
)

func getInstance() *instance {

	once.Do(func() {
		in = new(instance)
		in.cnt++

	})
	return in
}
func main() {
	for i := 0; i < 99; i++ {
		go func() {
			instance := getInstance()
			fmt.Println(instance.cnt)
		}()
	}
	time.Sleep(4 * time.Second)
}
